const createThemeColorReplacerPlugin = require('./src/config/plugin.config')
const path = require('path')

const resolve = dir => {
  return path.join(__dirname, dir)
}

module.exports = {
  pages: {
    index: {
      entry: 'src/main.js',
      title: '海南省水务建设市场信用信息平台'
    }
  },
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('_c', resolve('src/components'))
      .set('_conf', resolve('config'))
      .set('_public', resolve('public'))
  },
  // 打包时不生成.map文件
  productionSourceMap: false,
  runtimeCompiler: true,
  devServer: {
    port: 8080,
    proxy: {
      '/api': {
        // 代理地址，地址为/api/开始的会转向target
        target: 'http://localhost:8080/',//正式环境：http://218.77.183.153:9300  测试：http://172.16.26.40:8097
        // 如果接口跨域，需要进行这个参数配置
        changeOrigin: true,
        pathRewrite: { '^/api': '' }  // /api
      },

    }
  },
  configureWebpack: config => {
    config.plugins.push(createThemeColorReplacerPlugin());
  },
  css: {
    loaderOptions: {
      less: { javascriptEnabled: true } // 开启后 antd 样式 可以引用.less文件
    }
  }
}
